package com.fre;

import org.taptwo.android.widget.CircleFlowIndicator;
import org.taptwo.android.widget.ViewFlow;

import android.app.ActivityGroup;
import android.app.LocalActivityManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class MyFreakTestActivity extends ActivityGroup {

	LocalActivityManager  manager;

	CircleFlowIndicator indi;

	ViewFlow viewFlow;


	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		manager = getLocalActivityManager();

		indi = (CircleFlowIndicator)this.findViewById( R.id.viewflowindic );

		viewFlow = ( ViewFlow )this.findViewById( R.id.viewflow );

		viewFlow.setAdapter( new MyAdapter( MyFreakTestActivity.this ));
		viewFlow.setFlowIndicator(indi);
	}





	class MyAdapter extends BaseAdapter{

		public Context mContext;
		private Class<?>[] clsss;

		public MyAdapter( Context con ){

			this.mContext = con;
			clsss = new Class<?>[]{FrameOne.class, FrameTwo.class};
		}

		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return clsss.length;
		}

		@Override
		public Object getItem(int arg0) {
			// TODO Auto-generated method stub
			return clsss[arg0];
		}

		@Override
		public long getItemId(int arg0) {
			// TODO Auto-generated method stub
			return arg0;
		}

		@Override
		public View getView(int arg0, View arg1, ViewGroup arg2) {

			View view = manager.startActivity( "id" + Math.random(), new Intent(MyFreakTestActivity.this, clsss[arg0]) ).getDecorView();

			return view;
		}}
}